package com.yt.fras.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.yt.fras.mapper.ManagementGroupMapper;
import com.yt.fras.pojo.entity.ManagementGroup;
import com.yt.fras.pojo.model.ManagementGroupInfo;
import com.yt.fras.service.ManagementGroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.annotation.CacheConfig;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 * 管理组表 服务实现类
 * </p>
 *
 * @author yt
 * @since 2021-10-25
 */
@Service
@CacheConfig(cacheNames = "managementGroupCache")
public class ManagementGroupServiceImpl extends ServiceImpl<ManagementGroupMapper, ManagementGroup> implements ManagementGroupService {

    @Autowired
    private ManagementGroupMapper managementGroupMapper;

    @Override
    public List<ManagementGroupInfo> getGroupListByAdminId(String adminId) {
        return managementGroupMapper.getGroupListByAdminId(adminId);
    }

    @Override
    public List<ManagementGroupInfo> getGroupsByUserId(String userId) {
        return managementGroupMapper.getGroupsByUserId(userId);
    }

    @Override
    public ManagementGroup getGroupByCode(String code) {
        QueryWrapper<ManagementGroup> wrapper = new QueryWrapper<>();
        wrapper.eq("code", code);
        return managementGroupMapper.selectOne(wrapper);
    }

    @Override
    public ManagementGroupInfo getGroupById(String groupId) {
        return managementGroupMapper.getGroupById(groupId);
    }

}
